<template>
  <div class="home">
    <div style="margin-bottom: 5px">
      <span>你好！{{ user.username }}</span>
      <router-link to="/register?skip=edit" style="margin: 0 5px"><el-button type="primary" size="mini">修改用户信息</el-button></router-link>
      <el-button @click="exit()" type="danger" size="mini">退出</el-button>
    </div>
    <header-tab ></header-tab>

  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
import {getInfo} from "@/api/login";
import Cookies from "js-cookie";
import HeaderTab from "@/components/HeaderTab"

export default {
  name: 'HomeView',
  components: {
    HeaderTab
  },
  data() {
    return {
      user: {},
    }
  },
  created() {
    this.showUser()
  },
  methods: {
    login() {
      alert("敬请期待！！")
    },

    showUser() {
      getInfo().then((res) => {
        const info = res.data.user
        this.user = info
      })

    },
    exit() {
      // if (confirm("确认退出吗？"))
      const token = Cookies.get('token')
      Cookies.remove('token'); // 清除Token
      this.$message("安全退出")
      // 跳转到登录页面的代码
      this.$router.push({path: '/login'})
    },

    loading() {
      alert("敬请期待！！")
    }

  }
}
</script>

<style>
.home {
  overflow: hidden;
  width: 100%;
}
.left {
  width: 400px;
  margin-top: 15px;
  padding: 20px 30px 20px 5px;
}

.left form {

}

.left form .btnGroup {
  margin-left: 80px;
}
</style>
